<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>路由的使用</title>
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="vue-router.js"></script> -->
    <script src="../src/assets/vue.js"></script>
    <script src="../src/assets/vue-router.js"></script>
</head>

<body>
    <div id="app">
        <p>
            <router-link to="/news">新闻</router-link>
            <router-link to="/books">图书</router-link>
            <router-link to="/videos">视频</router-link>

        </p>
        <router-view></router-view>
    </div>

    <!-- 定义组件 -->
    <script>
        const news = { template: `<div>新闻页面</div>` }
        const books = { template: `<div>图书页面</div>` }
        const videos = { template: `<div>视频页面</div>` }

        const routes = [
            { path: '/news', component: news },
            { path: '/books', component: books },
            { path: '/videos', component: videos }
        ]

        // 创建route实例
        const router = new VueRouter({
            routes
        })

        // 创建挂载和根实例
        new Vue({
            el: '#app',
            router: router
        })
    </script>
</body>

</html>